import tensorflow as tf
from tensorflow import keras

(x, y), (x_test, y_test) = keras.datasets.mnist.load_data()
print(x.shape)   # (60000, 28, 28)
print(y.shape)   # (60000,)
print(x.min())   # 0
print(x.max())   # 255
print(x.mean())  # 33.318421449829934

print(x_test.shape)  # (10000, 28, 28)
print(y_test.shape)  # (10000,)
print(y[:4])

y_onehot = tf.one_hot(y, depth=10)
print(y_onehot[:2])

# 数据加载进入内存后，需要转换成Dataset对象
train_db = tf.data.Dataset.from_tensor_slices((x, y))

